Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Macintosh Toolbox Essentials

Previous | Chapter Top | Chapter Contents | Next |

Maintaining the Update Region

This section describes the functions you use to update your windows and to maintain window update regions.

BeginUpdate

Starts updating a window when you receive an update event for that window.

pascal void BeginUpdate (WindowPtr theWindow);
theWindow
A pointer to the window's window record. Your application gets this information from the message field in the update event record.

DESCRIPTION

The BeginUpdate function limits the visible region of the window's graphics port to the intersection of the visible region and the update region; it then sets the window's update region to an empty region. After calling BeginUpdate , your application redraws either the entire content region or only the visible region. In either case, only the parts of the window that require updating are actually redrawn on the screen.

Every call to BeginUpdate must be matched with a subsequent call to EndUpdate (EndUpdate) after your application redraws the content region. BeginUpdate and EndUpdate can't be nested. That is, you must call EndUpdate before the next call to BeginUpdate .

SPECIAL CONSIDERATIONS

If you don't clear the update region when you receive an update event, the Event Manager continues to send update events until you do.

EndUpdate

Finishes updating a window.

pascal void EndUpdate (WindowPtr theWindow);
theWindow
A pointer to the window's window record.

DESCRIPTION

The EndUpdate function restores the normal visible region of a window's graphics port. When you receive an update event for a window, you call BeginUpdate (BeginUpdate) , redraw the update region, and then call EndUpdate . Each call to BeginUpdate must be balanced by a subsequent call to EndUpdate .

InvalRect

Adds a rectangle to a window's update region.

pascal void InvalRect (const Rect *badRect);
badRect
A pointer to a rectangle, in local coordinates, that is to be added to a window's update region.

DESCRIPTION

The InvalRect function adds a specified rectangle to the update region of the window whose graphics port is the current port. Specify the rectangle in local coordinates. The Window Manager clips it, if necessary, to fit in the window's content region.

Both your application and the Window Manager use the InvalRect function. When the user enlarges a window, for example, the Window Manager uses InvalRect to add the newly created content region to the update region. Your application uses InvalRect to add the two rectangles formerly occupied by the scroll bars in the smaller content area.

InvalRgn

Adds a region to a window's update region.

pascal void InvalRgn (RgnHandle badRgn);
badRgn
The region, in local coordinates, that is to be added to a window's update region.

DESCRIPTION

The InvalRgn function adds a specified region to the update region of the window whose graphics port is the current port. Specify the region in local coordinates. The Window Manager clips it, if necessary, to fit in the window's content region.

ValidRect

Removes a rectangle from a window's update region.

pascal void ValidRect (const Rect *goodRect);
goodRect
A pointer to a rectangle, in local coordinates, to be removed from a window's update region.

DESCRIPTION

The ValidRect function removes a specified rectangle from the update region of the window whose graphics port is the current port. Specify the rectangle in local coordinates. The Window Manager clips it, if necessary, to fit in the window's content region.

Your application uses ValidRect to tell the Window Manager that it has already drawn a rectangle and to cancel any updates accumulated for that area. You can thereby improve response time by reducing redundant redrawing.

Suppose, for example, that you've resized a window that contains a size box and scroll bars. Depending on the dimensions of the newly sized window, the new size box and scroll bar areas may or may not have been accumulated into the window's update region. After calling SizeWindow (SizeWindow) , you can redraw the size box or scroll bars immediately and then call ValidRect for the areas they occupy. If they were in fact accumulated into the update region, ValidRect removes them so that you do not have to redraw them with the next update event.

ValidRgn

Removes a specified region from a window's update region.

pascal void ValidRgn (RgnHandle goodRgn);
goodRgn
A region, in local coordinates, to be removed from a window's update region.

DESCRIPTION

The ValidRgn function removes a specified region from the update region of the window whose graphics port is the current port. Specify the region in local coordinates. The Window Manager clips it, if necessary, to fit in the window's content region.


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next